package kr.hkit.androidcomplete03;

import kr.hkit.androidcomplete03.ch20.Ch20_Main;
import kr.hkit.androidcomplete03.ch21.Ch21Main;
import kr.hkit.androidcomplete03.ch22.Ch22Main;
import kr.hkit.androidcomplete03.ch23.Ch23Main;
import kr.hkit.androidcomplete03.ch25.Ch25Main;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ListActivity{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.chapter, android.R.layout.simple_list_item_1);
		setListAdapter(adapter);
		
	}
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		
		Intent intent = null;
		switch(position){
		case 0: intent = new Intent(this, Ch20_Main.class);
		break;
		case 1: intent = new Intent(this, Ch21Main.class);
		break;
		case 2: intent = new Intent(this, Ch22Main.class);
		break;
		case 3: intent = new Intent(this, Ch23Main.class);
		break;
		case 4: intent = new Intent(this, Ch25Main.class);
		break;
		}
		startActivity(intent);
	}
}
